What's Wrong With this Picture?
by Welopez

Code and images can be downloaded from http://jbusers.com/phpBB/viewtopic.php?p=497#497

This morning I woke up and said to myself, "Welopez, let's do something different today!"  Since I am not a very good artist, I thought I might like to try creating a simple image using MS Paint.  After doing that, since I am not much of a graphics guru, I thought I'd like to try creating a SPRITE.  If I were successful with those two tasks, I'd like to write DEMO programs to display a BMP image, and a SPRITE created by yours truly.

Creating the UFO image, no matter how poor it looks, wasn't difficult.  Mission one accomplished!  Before I could embark on task #2, I had to study a wee bit.  I went to the Liberty Newsletters, in particular the article on sprites in LB NL#132.  Aha, says I to myself!  Alyce makes it seem so simple!  So I created a UFO sprite.  Task #2 completed.

Only two tasks remaining.  Since I've had practice displaying BMP images, I chose to tackle that code first.  In Demo1, the thing I want to change automatically is the background color of the Window for Graphics.  Not a difficult task, simply put the FILL [i]color[/i] into a string, then use RND() and WORD$() to get a random color for fill.  Ahhh, that was easy!  Task #3 accomplished.

When you run the code, you'll notice the little UFO looks pretty good on a lightgray window, because I filled the image with lightgray for everything outside the UFO.  This works great if the color of the window is the same as the fill color of the BMP, but not so great when another color is used.  Two points for the BMP image:  It's quick, and easy, so long as you display it only over the fill color.

Now to tackle task #4.  I used techniques from Alyce and Janet to fill a Window for Graphics, GETBMP from the window position and add it to the program.  This has to be done before displaying the newColor$ as BACKGROUND bg.  Because this is a graphics window, we can change the color on the fly and we do this each time the UFO SPRITE has been displayed for 10 cycles.  Success!  Task #4 accomplished!

You'll notice the main difference between Demo1 and Demo2 is the branch to [getNewColor] for Demo2, as opposed to simply changing the "FILL  "; newColor$ we used in Demo1.

Okay, this tiny UFO is not very threatening, it doesn't drop biological terror weapons or attack with disintegrator rays, but it sure looks cool flitting around the window and no matter what color is used as a background, the SPRITE remains transparent over the background.  A background image could also be used.  Perhaps next time I'll add an asteroid to the background, and if the UFO and asteroid positions match, BOOM!  No more icky aliens!  That will teach the alien pilot to pay more attention to his driving....

